import uuid
from django.db import models


# 人员管理
class Person(models.Model):
    uuid = models.UUIDField(primary_key=True, default=uuid.uuid1, editable=False)
    dept = models.CharField("单位", max_length=50)
    name = models.CharField("姓名", max_length=50)
    phone = models.CharField("手机", max_length=50, unique=True)
    STATUS_CHOISE = (
        (0, "新创建"),
        (1, "申请中"),
        (2, "待入场"),
        (3, "已入场"),
        (4, "已出场"),
    )
    status = models.IntegerField("可用状态", choices=STATUS_CHOISE, default=0)
    begin_time = models.CharField("有效期开始", max_length=50, null=True, blank=True)
    end_time = models.CharField("有效期结束", max_length=50, null=True, blank=True)
    enter_time = models.CharField("入场时间", max_length=50, null=True, blank=True)
    enter_gate_name = models.CharField("入场道闸", max_length=50, null=True, blank=True)
    out_time = models.CharField("出场时间", max_length=50, null=True, blank=True)
    out_gate_name = models.CharField("出场道闸", max_length=50, null=True, blank=True)
    created = models.DateTimeField("创建时间", auto_now_add=True, null=True, blank=True)
    updated = models.DateTimeField("更新时间", auto_now=True, null=True, blank=True)

    def __str__(self):
        return f"人员<{self.name}>"

    class Meta:
        verbose_name = verbose_name_plural = "人员管理"
